$(function () {
    vm.getModelList();
});

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        project: {},
        modelEntityList: "",
        areaEntityList: ""
    },
    methods: {
        //查询
        getModelList: function () {
            $.get(baseURL + "ede/model/getAll", function (r) {
                vm.modelEntityList = r.modelEntityList;
            });
            $.get(baseURL + "ede/area/getAll", function (r) {
                vm.areaEntityList = r.areaEntityList;
            });
            vm.project.positionMode = '室内标准版';
            vm.project.debugMode = '炫舞模式';
        },
        save: function () {
            $('#save').button('loading').delay(1000).queue(function () {
                var project = vm.project.project;
                var modelId = vm.project.modelId;
                var positionMode = vm.project.positionMode;
                var area = vm.project.areaL;
                var debugMode = vm.project.debugMode;
                if (project == null || modelId == null || positionMode == null || area == null || debugMode == null||project.trim()=="") {
                    alert("必要数据不能为空！");
                    $('#save').button('reset');
                    $('#save').dequeue();
                    return;
                }
                let modelId_ =  document.getElementById('modelId');
                vm.project.modelName = modelId_.options[modelId_.selectedIndex].text;
                $.ajax({
                    type: "POST",
                    url: baseURL + "ede/project/save",
                    contentType: "application/json",
                    data: JSON.stringify(vm.project),
                    success: function (r) {
                        if (r.code === 0) {
                            $('#save').button('reset');
                            $('#save').dequeue();
                            parent.vm.addTab("编辑工程","#modules/front/myproject.html?id="+r.project.id);
                        } else {
                            layer.alert(r.msg);
                            $('#save').button('reset');
                            $('#save').dequeue();
                        }
                    }
                });
            });
        }
    }
});